<!DOCTYPE html>
<html >
 <head>
  <title>淡炒番茄 </title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta name="description" content="不知道为什么就是想写个网站玩儿，但技术不行将就用吧!"/>
  <meta name="viewport"  content="initial-scale=1, maximum-scale=3, minimum-scale=1, user-scalable=no"/>
  <meta name="renderer" content="webkit" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="keywords" content=""/>
  <meta name="robots" content="index,follow" />
  <meta name="full-screen" content="yes">
  <meta name="x5-fullscreen" content="true">
  <link href="../css/common.css" rel="stylesheet"/>
  <link href="../css/login.css" rel="stylesheet"/>
  <script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
  <script type="text/javascript" src="../js/smallarAlert.js"></script>
  <script type="text/javascript" src="../js/jquery.cookie.js"></script>
  <script type="text/javascript" src="../js/json2.js"></script>
  <script type="text/javascript">
  var ua = navigator.userAgent;
 
  window.onload = function(){ 
	  if(ua.match(/(iPhone|iPod|Android|ios)/i)){
		  $(".dfb").css("width","100%");
	  } 
  }; 
 
   
  	$(function(){
  		var userCookie = $.cookie('dcfqUsersInfo');
  		if(userCookie!=null){
  			var userObj=JSON.parse(userCookie);
  			$("#loginUser").val(userObj.loginUser);
  			$("#loginPwd").val(userObj.loginPwd);
  		}
  		
  	})
  	//跳转注册页面
  	function turnRegest(){
  		$("#login").hide();
  		$("#regester").show(600);
  	}
  	
  	//跳转登录页面
  	function turnLog(){
  		$("#regester").hide();
  		$("#login").show(600);
  	}
  	
  	//用户注册
  	function registerUser(){
  		var regeUser = $("#regeUser").val();
  		if(!regeUser){
  			alerts("请填写用户名！");
  			return false;
  		}
  		if(regeUser.length>5){
  			alerts("请填写用户名最多五个字！");
  			return false;
  		}
  		var regeEmail = $("#regeEmail").val();
  		if(!regeEmail.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)){
  			alerts("请填写正确邮箱！");
  			return false;
  		}
  		var pa=/^[0-9a-z]+$/i;
  		var regePawd = $("#regePawd").val();
  		var regePawd2 = $("#regePawd2").val();
  		if(!regePawd||!regePawd2){
  			alerts("密码错误！");
  			return false;
  		}
  		if(!regePawd&&regePawd.match(pa)){
  			alerts("密码格式错误！");
  			return false;
  		}
  		if(regePawd!=regePawd2){
  			alerts("密码输入不一致！");
  			return false;
  		}
  		
  		var values = {};
  		values["regeUser"]=regeUser;
  		values["regeEmail"] =regeEmail;
  		values["regePawd"]=regePawd;
  		$.post("../php/action/reigster.php",values,function(data){
  			if(data==3||data=="3"){
  				alerts("已有该用户名和邮箱,请重新注册!");
  			}else if(data==1||data=="1"){
  				alerts("注册成功!点击就可开启吐槽模式！");
  				window.location.replace("../index.php");
  			}else{
  				alerts("注册失败!请重新注册！");
  			}
  		});
  		  		
  	}
  	
  	//用户登录
  	function loginUserClick(){
	  	var loginPwd=$("#loginPwd").val();
	  	var loginUser = $("#loginUser").val();
	  	if(loginPwd==null||loginPwd==""||loginUser==null||loginUser==""){
	  		alerts("请填写用户名和密码！");
	  	}
	  	var loginInfo = {};
	  	loginInfo["loginUser"]=loginUser;
	  	loginInfo["loginPwd"]=loginPwd;
	  	$.post("../php/action/login.php",loginInfo,function(data){
	  		console.info(data);
	  		if(data==1||data=="1"){
	  			var jsonStr = JSON.stringify(loginInfo);
	  			//是否记住
	  			if($("#remberMe").is(":checked")){
	  				$.cookie("dcfqUsersInfo", jsonStr);
	  			}else{
	  				$.cookie("dcfqUsersInfo",  '', { expires: -1 });
	  			}
	  			
	  			alerts("登录成功。开启吐槽模式！");
	  			window.location.replace("../index.php");
	  		}else{
	  			alerts("用户名或密码错误");
	  		}
	  	});
  	}
  	
  	function forgetPwd(){//忘记密码
  		$("#login").hide();
  		$("#forgetDiv").show();
  	}
  	
  	function turnFromEmail(){
  		$("#login").show();
  		$("#forgetDiv").hide();
  	}
  	function sendEmail(){
  		var forgetEmail = $("#forgetEmail").val();
  		if(!forgetEmail.match(/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/)){
  			alerts("请填写正确邮箱！");
  			return false;
  		}
  		
  		$.post("../php/action/sendEmail.php",{"forgetEmail":forgetEmail},function(data){
  			console.info(data);
  			if(data==0){
  				alerts("发送成功，请根据随机码进入登录界面登录！");
  				turnFromEmail();
  			}
  		})
  	}
  	
  	function alertLog(message){
  		$.MsgBox({type:"alert",speed:200,title:"登录",msg:message,opacity:'0.5',callback:function(){
  			window.location.replace("../index.php");
  		}});
  	}
  	
  	function alerts(message){
  		$.MsgBox({type:"alert",speed:200,title:"登录",msg:message,opacity:'0.5',callback:function(){}});
  	}
  </script>
</head>
<body class="dfb">
	<div class="bodco bodyd" >
		<div class="contbt" >
			<ul>
				<li><a href="list.php?type=2" class="fonts1 font3 remFlo clicks1">小技术</a></li>
				<li><p  class="fonts font1">|</p></li>
				<li><a href="list.php?type=1" class="fonts1 font3 remFlo clicks1">小信息</a></li>
			</ul>
		</div>
		<div class="contnr">
			<div class="logindiv" id="login" >
				<form class="loginForm" action="" method="post" >
					 <ul>
					 	<li>
		                    <div class="fonts font2 longinbt" >
		                        	用户(五个字以内):<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="text">
		                        <span class="yonghu longintb"></span><input class="longco" type="text" placeholder="淡炒番茄" id="loginUser" />
		                    </div>
		                </li>
		                <li>
		                    <div class="fonts font2 longinbt">
		                        	密码:<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="password">
		                        <span class="mima longintb"></span><input class="longco" type="password" placeholder="••••••••••••••" id="loginPwd"/>
		                    </div>
		                </li>
		                <li class="remember">
		                    <input type="checkbox" id="remberMe" />记住我
		                </li>
		                <li>
		                    <a href="javascript:void(0)"  class="fonts font2" onclick="forgetPwd();">忘记密码?</a>&nbsp;|&nbsp;
		                    <a href="javascript:void(0)" onclick="turnRegest();"  class="fonts font2">注册</a>
		                </li>
		                <li>
		                    <input type="button" class="Logins" value="登录" onclick="loginUserClick();">
		                </li>
		            </ul>
				</form>
			</div>
			<div class="logindiv" id="forgetDiv" style="display: none; height:200px; ">
				<form class="loginForm" action="" method="post" style="height:200px; " >
					 <ul>
					 	<li>
		                    <div class="fonts font2 longinbt" >
		                        	邮箱（注册邮箱）:<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="text">
		                        <span class="yonghu longintb"></span><input class="longco" type="text" placeholder="xxxx@qq.com" id="forgetEmail" />
		                    </div>
		                </li>
		                <li>
		                    <a href="javascript:void(0)" onclick="turnFromEmail();"  class="fonts font2">登录</a>
		                </li>
		                <li>
		                    <input type="button" class="Logins" value="发送" onclick="sendEmail();">
		                </li>
		            </ul>
				</form>
			</div>
			<div class="xiugaidiv" >
				<form class="xiugaiForm" action="" method="post" >
					
				</form>
			</div>
			<div class="zhucediv"  id="regester" style="display: none;">
				<form class="zhuceForm" action="" method="post" >
					 <ul>
					 	<li>
		                    <div class="fonts font2 longinbt" >
		                        	用户名:<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="text">
		                        <span class="yonghu longintb"></span>
		                        <input class="longco" type="text" placeholder="淡炒番茄" id="regeUser"/>
		                    </div>
		                </li>
		                <li>
		                    <div class="fonts font2 longinbt" >
		                        	EMAIL(用于找回密码):<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="text">
		                        <span class="yonghu longintb"></span>
		                        <input class="longco" type="text" placeholder="xxxx@xx.com" id="regeEmail"/>
		                    </div>
		                </li>
		                <li>
		                    <div class="fonts font2 longinbt">
		                        	密码（由数字、字母组成）:<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="password">
		                        <span class="mima longintb"></span>
		                        <input class="longco" type="password" placeholder="••••••••••••••" id="regePawd"/>
		                    </div>
		                </li>
		                 <li>
		                    <div class="fonts font2 longinbt">
		                        	再次输入密码:<span style="color: red;">*</span>
		                    </div>
		                </li>
		                <li>
		                    <div class="password">
		                        <span class="mima longintb"></span>
		                        <input class="longco" type="password" placeholder="••••••••••••••" id="regePawd2"/>
		                    </div>
		                </li>
		                <li>
		                    <a href="javascript:void(0)" onclick="turnLog();" class="fonts font2">登录</a>
		                </li>
		                <li>
		                    <input type="button" class="Logins" value="注册" onclick="registerUser();">
		                </li>
		            </ul>
				</form>
			</div>
		</div>
	</div>
	<div class="bodco bodcohrs" ><hr class="bodyh"/></div> 
 	<div class="bodco bodyf">
 		 <p class='fonts font2'> @2016-2017 <a  href="../index.php" class='fonts font2 ' style="text-decoration: none;" >淡炒番茄</a> （http://www.dancfq.top/)  备案号:蜀ICP备16034800号 </p>
 	</div>
</body>
</html>